from django.db import models
from django.contrib.auth.models import User
from datetime import datetime    
from django.template.defaultfilters import slugify


class Discussion(models.Model):
    sent_from=models.ForeignKey(User,null=True,blank=True,related_name='sent from')
    sent_to=models.ForeignKey(User,null=True,blank=True,related_name='sent to')
    message=models.TextField(null=False,blank=False)
    sent_date=models.DateTimeField(verbose_name='Message date', auto_now_add=True)
    status_sent_from=models.CharField(max_length=20,null=False,blank=False,default='ACTIVE')
    status_sent_to=models.CharField(max_length=20,null=False,blank=False,default='ACTIVE')

class Referral(models.Model):
    sent_date=models.DateTimeField(verbose_name='Referral date', auto_now_add=True)
    refered=models.ForeignKey(User,null=True,blank=True,related_name='refered')
    refered_by=models.ForeignKey(User,null=True,blank=True,related_name='refered_by')
    case_no=models.CharField(max_length=255,null=True,blank=True)
    case=models.TextField(null=False,blank=False,verbose_name="Case Details *")
    status=models.CharField(max_length=20,null=True,blank=True)
    discussion=models.ManyToManyField(Discussion,verbose_name='Discussions')
    def __str__(self):
        return self.case
